import request from '@/utils/request'
import storage from '@/utils/storage'
import constant from '@/utils/constant'

//地址列表查询方法
export function getAddressByUserId(isdefault) {
  const data = {}
	if(isdefault == 1){data.isdefault = 1}
	console.log(storage.get(constant.user));
	data.userid = storage.get(constant.user).userId
  return request({
    'url': '/printer/addressManage/list',
    headers: {
      isToken: true
    },
    'method': 'get',
    'data': data
  })
}

//地址更新方法
export function updataAddress(data) { 
  return request({
    'url': '/printer/addressManage',
    headers: {
      isToken: true
    },
    'method': 'put',
    'data': data
  })
}

//地址添加方法
export function addAddress(data) { 
	data.userid = storage.get(constant.user).userId
  return request({
    'url': '/printer/addressManage',
    headers: {
      isToken: true
    },
    'method': 'post',
    'data': data
  })
}

//地址删除方法
export function deleteAddress(id) {
  return request({
    'url': '/printer/addressManage/'+id,
    headers: {
      isToken: true
    },
    'method': 'delete'
  })
}

//地址删除方法
export function setDefaultAddress(id) {
  return request({
    'url': '/printer/addressManage/'+id,
    headers: {
      isToken: true
    },
    'method': 'delete'
  })
}